package com.alibaba.middleware.hsf.protostuff;

import com.alibaba.middleware.hsf.Data;
import com.alibaba.middleware.hsf.guide.api.model.OrderModel;

import io.protostuff.LinkedBuffer;
import io.protostuff.ProtostuffIOUtil;
import io.protostuff.runtime.RuntimeSchema;

/**
 * @author weipeng2k 2017年12月27日 上午10:31:16
 */
public class Serial {

    public static void main(String[] args) {
        RuntimeSchema<OrderModel> schema = RuntimeSchema.createFrom(OrderModel.class);
        byte[] array = ProtostuffIOUtil.toByteArray(Data.gen(), schema,
                LinkedBuffer.allocate(LinkedBuffer.DEFAULT_BUFFER_SIZE));
        System.out.println(array.length);

        OrderModel message = schema.newMessage();
        ProtostuffIOUtil.mergeFrom(array, message, schema);
        System.out.println(message);
    }
}
